﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CMN.BLL;
using CMN.Common;
using CMN.Entity;
using CMN.Models.Interfaces;
namespace CMN.Models
{
    /// <summary>
    /// 通知公告Service
    /// </summary>
    public class Normal_NoticeService: IDataService<Normal_NoticeEntity>
    {
        /// <summary>
        /// 新增通知公告
        /// </summary>
        /// <param name="Normal_NoticeEntity"></param>
        /// <returns>bool</returns>
        public string Insert(Normal_NoticeEntity normal_noticeEntity)
        {
            Normal_Notice bll = new Normal_Notice();
            normal_noticeEntity.DataTable_Action = DataTableAction.Insert;
            if (bll.InsertUpdateDelete(normal_noticeEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 返回通知公告查询列表
        /// </summary>
        /// <param name="qp"></param>
        /// <param name="count">查询总个数</param>
        /// <returns>List</returns>
        public List<Normal_NoticeEntity> List(QueryParam qp,out int count)
        {
            Normal_Notice bll = new Normal_Notice();
            return bll.List(qp, out count);
        }

        /// <summary>
        /// 更新通知公告
        /// </summary>
        /// <param name="Normal_Notice"></param>
        /// <returns>bool</returns>
        public string Update(Normal_NoticeEntity normal_noticeEntity)
        {
            Normal_Notice bll = new Normal_Notice();
            normal_noticeEntity.DataTable_Action = DataTableAction.Update;
            if (bll.InsertUpdateDelete(normal_noticeEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 删除通知公告
        /// </summary>
        /// <param name="Normal_Notice"></param>
        /// <returns>bool</returns>
        public string Delete(Normal_NoticeEntity normal_noticeEntity)
        {
            Normal_Notice bll = new Normal_Notice();
            normal_noticeEntity.DataTable_Action = DataTableAction.Delete;
            if (bll.InsertUpdateDelete(normal_noticeEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 批量删通知公告
        /// </summary>
        /// <param name="idList">删除id列表  2_8_9_45</param>
        /// <returns>bool</returns>
        public string DeleteList(string idList)
        {
            Normal_Notice bll = new Normal_Notice();
            string[] list =Utils.SplitString(idList,"_");
            string strDel=Utils.ArrayToString(list,",",false);
            if (bll.DelList(strDel) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }

        }

        /// <summary>
        /// 返回单个通知公告
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Normal_NoticeEntity</returns>
        public Normal_NoticeEntity Look(int id)
        {
            Normal_Notice bll = new Normal_Notice();
            return bll.Disp(id);
        }
    }
}
